def prostoe(k):
    for y in range(2, int(k**0.5)+1):
        if(k%y==0):
            return True
            break
    return False


a = list(input().split())
b = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
n = ''
s = 0
d = True
for i in a:
    if i not in b:
        d = False
        break
    
if(d == True and len(a)==3):
    for j in range(10):
        if(a[0]==b[j]):
            s += j*100
        if(a[1]==b[j]):
            s += j*10
        if(a[2]==b[j]):
            s += j
    plus = s
    minus = s
    while(prostoe(plus)):
        plus += 1
    while(prostoe(minus)):
        minus -= 1
    if(plus-s>=s-minus):
        n = str(minus)
    else:
        n = str(plus)
    if(len(n) == 1):
        n = '00' + n
        print(n)
    elif(len(n) == 2):
        n = '0' + n
        print(n)
    else:
        print(n)
else:
    print('Wrong input')
    

    
